<div class="bjui-pageContent">
    <form action="${wwwroot}/admin/server/save" id="editForm" data-toggle="validate" data-alertmsg="false" reloadNavtab="true">
        <input type="hidden" name="id" value="${(server.id)!}" />
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                    <tr>
                        <td>
                            <label for="alias" class="control-label x85">别名：</label>
                            <input type="text" name="alias" id="alias" value="${(server.alias)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="agentId" class="control-label x85">代理：</label>
                            <#--<input type="text" name="agentId" id="agentId" value="${(server.agentId)!}"  >-->
                            <select name="agentId" id="agentId" data-toggle="selectpicker" data-rule="required">
                                <option value="">请选择</option>
                            <#list agents as ag>
                                <option value="${(ag.id)!}" <#if ag??&&ag.id??&&server.agentId??&&ag.id==server.agentId>selected</#if>>${(ag.name)!}</option>
                            </#list>
                            </select>
                        </td>
                        <#--<td>-->
                            <#--<label for="groupType" class="control-label x85">分组类型：</label>-->
                            <#--<input type="text" name="groupType" id="groupType" value="${(server.groupType)!}" data-rule="required" >-->
                        <#--</td>-->
                        <td>
                            <label for="bizTypeId" class="control-label x85">业务类型：</label>
                        <#--<input type="text" name="bizTypeId" id="bizTypeId" value="${(server.bizTypeId)!}"  >-->
                            <select name="bizTypeId" id="bizTypeId" data-toggle="selectpicker" onchange="$('#bizTypeName_').val(this.options[this.selectedIndex].text)" data-rule="required">
                                <option value="">请选择</option>
                            <#list bizTypes as type>
                                <option value="${(type.id)!}" <#if type??&&type.id??&&server.bizTypeId??&&type.id==server.bizTypeId>selected</#if>>${(type.typeName)!}</option>
                            </#list>
                            </select>
                            <input type="hidden" name="bizTypeName" id="bizTypeName_" value="${(server.bizTypeName)!}"  >
                        </td>
                    </tr>
                    <tr>

                        <td>
                            <label for="host" class="control-label x85">地址：</label>
                            <input type="text" name="host" id="host" value="${(server.host)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="user" class="control-label x85">账号：</label>
                            <input type="text" name="user" id="user" value="${(server.user)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="pass" class="control-label x85">密码：</label>
                            <input type="password" name="pass" id="pass" value="${(server.pass)!}" data-rule="required" onchange="javascript:genPass()">
                        </td>
                    </tr>
                    <tr>

                    <#--<td>-->
                    <#--<label for="bizTypeName" class="control-label x85">业务类型名称：</label>-->
                    <#--<input type="text" name="bizTypeName" id="bizTypeName" value="${(server.bizTypeName)!}"  >-->
                    <#--</td>-->
                        <td>
                            <label for="opSystem" class="control-label x85">操作系统：</label>
                        <@p.selector osTypes 'typeName' 'typeName' server 'opSystem' 'opSystemName'/>
                        <#--<input type="text" name="opSystem" id="opSystem" value="${(server.opSystem)!}"  >-->
                        </td>
                        <td>
                            <label for="sysRank" class="control-label x85">系统级别：</label>
                        <@p.selector systemRanks 'name' 'name' server 'sysRank' 'sysRankName'/>
                        <#--<input type="text" name="sysRank" id="sysRank" value="${(server.sysRank)!}"  >-->
                        </td>
                        <td>
                            <label for="note" class="control-label x85">备注：</label>
                            <input type="text" name="note" id="note" value="${(server.note)!}"  >
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="team" class="control-label x85">组别：</label>
                            <select name="team" id="team" data-toggle="selectpicker"  data-rule="required">
                                <option value="">请选择</option>
                            <#list teams as team>
                                <option value="${(team)!}" <#if team??&&team.value??&&server.team??&&team==server.team>selected</#if>>${(team.label)!}</option>
                            </#list>
                            </select>
                        </td>
                        <td>
                            <label for="customParam" class="control-label x85">自定义参数：</label>
                            <input type="text" name="customParam" id="customParam" value="${(server.customParam)!}"  >
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a class="btn btn-success" href="javascript:testConnect();">测试连接</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<div class="bjui-pageFooter" >
    <ul>
        <li><button type="button" class="btn btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn btn-success" data-icon="save">保存</button></li>
    </ul>
</div>
<script>
function genPass()
{
    var pass = $('#pass').val();
    $.ajax({
        url: "/admin/pass/encrypt"
        , type: "POST"
        , data: "pass="+pass
        , success: function( data, textStatus, jqXHR ){
            $('#pass').val(data)
        }
    });
}
  function testConnect(){
      var opSystem = $('#editForm select[id=opSystem]').val();
      var host = $('#editForm input[id=host]').val();
      var user = $('#editForm input[id=user]').val();
      var pass = $('#editForm input[id=pass]').val();

      $.ajax({
          url: "/admin/server/testconnect"
          , type: "POST"
          , data: "opSystem="+opSystem+"&host="+host+"&user="+user+
          "&pass="+pass+"&random="+new Date().getTime()
          ,timeout:5000
          , success: function( data, textStatus, jqXHR ){
              alert(data);
          }
      });
  }
</script>